#if _MSC_VER>1000
#pragma once
#endif


class AuSample{
public:
	BYTE *samples;
	int numsamples,bps,nch,srate;
	int Seek;
public:
	virtual int open(int,int,int)=0;
	virtual int write(BYTE *,int,int,int,int)=0;
	virtual void close()=0;
	virtual void flush()=0;

};
class ImageSample{
public:
	virtual void Init()=0;
	virtual void Process(RGBTRIPLE *prgb,int cxImage,int cyImage)=0;
	virtual void Configure(HWND hwnd)=0;
	virtual void Quit()=0;
};

typedef  ImageSample* (*INIT)();

/*typedef struct
{
	
	// dsp plug-in processing:
	// (filled in by winamp, called by input plug)

	int (*dsp_dosamples)();
	int (*dsp_isactive)();
	// eq stuff
	AuSample* (*GetData)(); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore.


} DspMod;*/

DECLARE_INTERFACE_(IAuFilter,IUnknown)
{
	STDMETHOD(SetDspfunction)(THIS_ AuSample*)PURE;
	STDMETHOD(SetStop)(THIS_)PURE;
	//STDMETHOD(GetSample)(THIS_ AuSample*)PURE;
};
DECLARE_INTERFACE_(IFilterInterface,IUnknown)
{

	STDMETHOD (SetOptions)(THIS_ int topt)PURE;
	STDMETHOD (SetSmooth)(THIS_ int topts)PURE;
	STDMETHOD (SetExtEff)(THIS_ int teopt)PURE;
	STDMETHOD (SetExtEff)(THIS_ char*fname)PURE;
	STDMETHOD (SetConfigure)(THIS_ HWND hwnd)PURE;
	STDMETHOD (SetStop)(THIS_)PURE;

};


//DECLARE_INTERFACE_(
class AuFilter:public CTransInPlaceFilter,public IAuFilter
{
public:
	DECLARE_IUNKNOWN;

	static CUnknown *CreateInstance(LPUNKNOWN,HRESULT*);
	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void ** ppv);
	HRESULT Transform(IMediaSample *pSample);
	//HRESULT DoRenderSample(IMediaSample *pMediaSample);
	//HRESULT BeginFlush(void);
		
	HRESULT CheckInputType(const CMediaType*pmtin);
	
	STDMETHODIMP SetDspfunction(AuSample*);
	STDMETHODIMP SetStop();
	//STDMETHODIMP GetSample(AuSample *);
public:
	AuSample*mod;
private:
	AuFilter(TCHAR*,LPUNKNOWN,HRESULT*);
	//CCritSec            m_GargleLock;
	WAVEFORMATEX wf;
};
class Filter:public CTransInPlaceFilter,
			 public ISpecifyPropertyPages,
			 public IFilterInterface
			
{
public:
	
	STDMETHOD(SetExtEff)(int teopt);
	int eopt;
	STDMETHOD(SetExtEff)(char *fname);
	DECLARE_IUNKNOWN;
	static CUnknown* CreateInstance(LPUNKNOWN,HRESULT*);

	// Reveals IFilter and ISpecifyPropertyPages
    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);

	HRESULT Transform(IMediaSample*pSample);
	HRESULT CheckInputType(const CMediaType*pmtin);

	// ISpecifyPropertyPages interface
    STDMETHODIMP GetPages(CAUUID *pPages);
	STDMETHODIMP SetOptions(int topt);
	STDMETHODIMP SetSmooth(int topts);
	STDMETHODIMP SetConfigure(HWND);
	STDMETHODIMP SetStop();
		
private:
	Filter(TCHAR*,LPUNKNOWN,HRESULT*);
	double T;
	int opt;
	int t;
protected:
	ImageSample *img;
	INIT Init;
	HMODULE hmod;
	int opts;
	int Smooth(const RGBTRIPLE*ttop,const int cxImage,const int cyImage);
};

class FilterProp:public CBasePropertyPage
{
public:
	HRESULT OnDisconnect();
	HRESULT OnConnect(IUnknown *pIUnknown);
	BOOL OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
	//DEFINE_IUNKNOWN;
	static CUnknown * WINAPI CreateInstance(LPUNKNOWN punk,HRESULT*phr);
	
private:
	FilterProp(LPUNKNOWN punk,HRESULT*phr);
	IFilterInterface *pIFilterInterface;

};
AuSample* GetData();

//#ifdef __cplusplus
//}
//#endif